package cn.topevery.garden.dal.logic;

import cn.topevery.garden.dal.dao.CriterionEvaluationDao;
import cn.topevery.garden.entity.po.CriterionDef;
import cn.topevery.garden.entity.po.CriterionEvaluation;
import cn.topevery.garden.entity.query.CriterionEvaluationQuery;
import cn.topevery.garden.entity.vo.CriterionEvaluationVO;
import cn.topevery.garden.framework.base.BaseLogic;
import hw.topevery.framework.db.base.BaseEntityDao;
import hw.topevery.framework.db.entity.DataPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 
 *
 * @author code-generate
 * @date 2022-01-05
 */
@Service
public class CriterionEvaluationLogic extends BaseLogic<CriterionEvaluation> {
    @Autowired
    CriterionEvaluationDao criterionEvaluationDao;

    @Override
    public BaseEntityDao<CriterionEvaluation, Integer> getDao() {
        return criterionEvaluationDao;
    }

    

    /**
     * 获取列表
     *
     * @param query
     */
    public DataPager<CriterionEvaluationVO> listPage(CriterionEvaluationQuery query) {
        return criterionEvaluationDao.listPage(query);
    }

    /**
     * 根据自增id批量删除
     *
     * @param ids
     */
    public void deleteBatchById(String userId,Integer[] ids) {
        criterionEvaluationDao.delete(userId, ids);
    }

    /**
     * 根据自增id保存或者更新
     *
     * @param criterionEvaluation 实体
     */
    public void saveOrUpdate(String userId, CriterionEvaluation criterionEvaluation){
        criterionEvaluationDao.saveOrUpdate(userId,criterionEvaluation);
    }

    /**
         * 根据自定义列值来获取对象
         */
    public CriterionEvaluation getEntityByColumn(String key, String value) {
        return criterionEvaluationDao.getEntityByColumn(key, value);
    }

    public void evaluation(List<CriterionEvaluation> evaluationList, Integer userId){
         criterionEvaluationDao.evaluation(evaluationList,userId);
    }

    public List<CriterionEvaluation> getListByCriterionId(String criterionId){
        return criterionEvaluationDao.getListByCriterionId(criterionId);
    }

    public void updateCountWhenPartakeChange(String criterionId, Integer flag){
         criterionEvaluationDao.updateCountWhenPartakeChange(criterionId,flag);
    }

    public void yearForNewData(){
         criterionEvaluationDao.yearForNewData();
    }

    public List<CriterionEvaluation> getRelationListByCriterionIdAndMapId(List<CriterionDef> criterionList, String mapId) {
        return criterionEvaluationDao.getRelationListByCriterionIdAndMapId(criterionList, mapId);
    }
}
